#include "Blocks/SeedsBlock.h"
#include "Blocks/TallGrassBlock.h"
#include "Blocks/RedFlowerBlock.h"
#include "Blocks/PurpleFlowerBlock.h"
#include "Blocks/WhiteFlowerBlock.h"
#include "Blocks/RyeBlock.h"
#include "Blocks/CottonBlock.h"
#include "Blocks/PumpkinBlock.h"

namespace PocketSurvival
{
    enum class SeedType
	{
		TallGrass,
		RedFlower,
		PurpleFlower,
		WhiteFlower,
		WildRye,
		Rye,
		Cotton,
		Pumpkin,

        SeedCount
	};

    void SeedsBlock::getCreativeValues(std::vector<int32_t> &blockVec)
    {
        for(int32_t index = 0; index < (uint8_t)SeedType::SeedCount; ++index)
        {
            blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, index));
        }
    }

    BlockPlacementData SeedsBlock::getPlacementValue(ComponentMiner *componentMiner, int32_t value, const TerrainRaycastResult &raycastResult)
    {
		BlockPlacementData result;
		result.cellFace = raycastResult.cellFace;
		if (raycastResult.cellFace.face == 4)
		{
			switch ((SeedType)Terrain::ExtractData(value))
			{
			case SeedType::TallGrass:
				result.value = Terrain::MakeBlockValue(TallGrassBlock::Index(), 0, TallGrassBlock::SetIsSmall(0, true));
				break;
			case SeedType::RedFlower:
				result.value = Terrain::MakeBlockValue(RedFlowerBlock::Index(), 0, FlowerBlock::SetIsSmall(0, true));
				break;
			case SeedType::PurpleFlower:
				result.value = Terrain::MakeBlockValue(PurpleFlowerBlock::Index(), 0, FlowerBlock::SetIsSmall(0, true));
				break;
			case SeedType::WhiteFlower:
				result.value = Terrain::MakeBlockValue(WhiteFlowerBlock::Index(), 0, FlowerBlock::SetIsSmall(0, true));
				break;
			case SeedType::WildRye:
				result.value = Terrain::MakeBlockValue(RyeBlock::Index(), 0, RyeBlock::SetSize(RyeBlock::SetIsWild(0, false), 0));
				break;
			case SeedType::Rye:
				result.value = Terrain::MakeBlockValue(RyeBlock::Index(), 0, RyeBlock::SetSize(RyeBlock::SetIsWild(0, false), 0));
				break;
			case SeedType::Cotton:
				result.value = Terrain::MakeBlockValue(CottonBlock::Index(), 0, CottonBlock::SetSize(CottonBlock::SetIsWild(0, false), 0));
				break;
			case SeedType::Pumpkin:
				result.value = Terrain::MakeBlockValue(PumpkinBlock::Index(), 0, BasePumpkinBlock::SetSize(BasePumpkinBlock::SetIsDead(0, false), 0));
				break;
			}
		}
		return result;
    }

    int32_t SeedsBlock::getIndex()
    {
        return Index();
    }
    const std::string &SeedsBlock::getBlockName()
    {
        static std::string blockName = "SeedsBlock";
        return blockName;
    }
	
} // namespace PocketSurvival
